﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class D07_OverlapSphere : MonoBehaviour
{
    public float radius = 5f;
    private Collider[] aroundColliders;
    public LayerMask layer;
    private void Start()
    {
        aroundColliders = new Collider[100];
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            int n = Physics.OverlapSphereNonAlloc(transform.position, radius, aroundColliders);
            for (int i = 0; i < n; i++)
            {
                aroundColliders[i].ChangeColor(Color.red);
            }
        }
    }

    private void OnDrawGizmos()
    {
        Gizmos.color = Color.red;
        Gizmos.DrawWireSphere(transform.position, radius);
        Gizmos.color = Color.white;
    }
}